<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
  <body>
    <div id="container"></div>
    <script src="kinetic-v4.1.2.min.js"></script>
    <script>
      var stage = new Kinetic.Stage({
        container: 'container',
        width: 578,
        height: 200
      });
      var layer = new Kinetic.Layer();

      var imageObj = new Image();
      imageObj.onload = function() {
        var yoda = new Kinetic.Image({
          x: 140,
          y: stage.getHeight() / 2 - 59,
          image: imageObj,
          width: 106,
          height: 118
        });

        var filteredYoda = new Kinetic.Image({
          x: 320,
          y: stage.getHeight() / 2 - 59,
          image: imageObj,
          width: 106,
          height: 118
        });

        // add the shape to the layer
        layer.add(yoda);
        layer.add(filteredYoda);

        // add the layer to the stage
        stage.add(layer);

        // apply grayscale filter to second image
        filteredYoda.applyFilter(Kinetic.Filters.Grayscale, null, function() {
          layer.draw();
        });
      };
      imageObj.src = 'http://www.html5canvastutorials.com/demos/assets/yoda.jpg';
    </script>
  </body>
</html>
